package config

import (
	"github.com/spf13/viper"
	oafviper "inspector/pkg/viper"
	"sync"
)

type IConfig interface {
	GetLogConfig() LogConfig
	GetServerConfig() ServerConfig
	GetMySQLConfig() MySQLConfig
	GetAtomConfig() AtomConfig
}

type Config struct{}

var instance *Config
var once sync.Once
var Viper *viper.Viper

func init() {
	once.Do(func() {
		Viper = oafviper.ConfigInitWithPrefix("", "config").Viper
		initLogConfig(Viper)
		initServerConfig(Viper)
		initMySQLConfig(Viper)
		initAtomConfig(Viper)
	})
}

func Get() IConfig {
	return instance
}
